package com.llmcu.source.java8.java8inaction.chapter12;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;

/**
 * LocalDate常用方法
 *
 * @author liuling
 * @date 2024-12-12 10:42
 */
public class LocalDateDemo {
    public static void main(String[] args) {
        // 1. 通过静态工厂方法创建对象
        LocalDate localDate = LocalDate.of(2024, 2, 29);
        int year = localDate.getYear();
        Month month = localDate.getMonth();
        int dayOfMonth = localDate.getDayOfMonth();
        DayOfWeek dayOfWeek = localDate.getDayOfWeek();
        int lengthOfMonth = localDate.lengthOfMonth();
        boolean leapYear = localDate.isLeapYear();

        // 2. now()方法创建对象
        LocalDate localDate1 = LocalDate.now();

        System.out.println("year:" + year);
        System.out.println("month:" + month);
        System.out.println("dayOfMonth:" + dayOfMonth);
        System.out.println("dayOfWeek:" + dayOfWeek);
        System.out.println("lengthOfMonth:" + lengthOfMonth);
        System.out.println("leapYear:" + leapYear);
        System.out.println("localDate1:" + localDate1);

    }
}
